﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;

namespace PRGexample.Controllers
{
    public class Home2Controller : Controller
    {
		static List<string> quotes = new List<string>();

		[HttpGet,  ImportModelStateResultFromTempData]
		public ActionResult Index()
		{
			return View(quotes);
		}

		[HttpGet]
		public ActionResult Add()
		{
			return View();
		}

		[HttpPost, ExportModelStateResultToTempData("Saved")]
		public ActionResult Save(string quote)
		{
			if (!string.IsNullOrEmpty(quote) && !quotes.Contains(quote))
			{
				quotes.Add(quote);
			}
			else
			{
				ModelState.AddModelError("", "Is Empty");
			}

			return RedirectToAction("Index");
		}
    }
}